Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get a human readable pattern for a route #74

Merged
merged 1 commit into from
Dec 15, 2019

Conversation

anuragsoni
Copy link
Owner

Closes: #64

@anuragsoni
Copy link
Owner Author

anuragsoni commented Dec 15, 2019

@sazarkin Sorry for taking this long. I guess nobody wanted to pick this up for Hacktoberfest 😄

Is this close to what you were looking for? This should allow you get the string representation of the route patterns. I've also added some pretty printers and used that to provide top level printers for utop.

@anuragsoni anuragsoni merged commit 16e2163 into master Dec 15, 2019
@anuragsoni anuragsoni deleted the print-route-pattern branch December 15, 2019 19:22
@anuragsoni
Copy link
Owner Author

anuragsoni commented Dec 16, 2019

The top level printers look like

utop # let handler a b = a + b;;
val handler : int -> int -> int = <fun>

utop # let r = handler <$ s "foo" </> int </> int;;
val r : int t = Route: foo/<int>/<int>

utop # with_method [`GET, r; `POST, handler <$ s "bar" </> s "baz" *> int </> int];;
- : int router = Routes:
> GET foo/<int>/<int>
> POST bar/baz/<int>/<int>

The string value can be accessed by the new functions added to the Routes module.

@sazarkin
Copy link

Thanks a lot!

anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 18, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 19, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 20, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to get human readable name for route
2 participants